let app = getApp()
var stylecss = require('../../utils/stylecss.js');
Component({
    properties: {
      scrollTop: {
        type: Number,
        observer: function(newVal, oldVal) {
          this.updatscroll()
        }
      },
      item:Object,
      vueId:String
      }, 
      data:{
      
      },
    lifetimes: {
      ready: function() {
        let that = this;
        const query = wx.createSelectorQuery().in(this)
        setTimeout(() => { 
           query.select('#'+this.data.vueId).boundingClientRect(res=>{
            if(res==null){
              that.setData({
                  top:0
              })
            }else{
             that.setData({
               top:res.top
             })
            }
              }).exec();
         }, 0);
       },
        attached: function () {
          var css=stylecss.css(this.data.vueId);
          var anima=stylecss.animated(this.data.vueId);
          this.setData({
            oldanima:anima,
            anima:anima,
            css:css
          })
       }
      },
    methods: {
      updatscroll:function(){
        var nowtop=this.data.scrollTop-this.data.top
        var oldanima=this.data.oldanima
        if(nowtop<=0){
         this.setData({
           anima:oldanima
         })
        }else{
          this.setData({
              anima:''
          })
        }
     },
      jumpurl:function(e){
        stylecss.jumpurl(this.data.item.link);
      }
    }
});
